package com.gzs.zhdj.controller;

import com.gzs.zhdj.domain.dto.AnswerDto;
import com.gzs.zhdj.domain.dto.PageBean;
import com.gzs.zhdj.domain.dto.QAPageDto;
import com.gzs.zhdj.domain.dto.QuestionDto;
import com.gzs.zhdj.service.QAService;
import com.gzs.zhdj.utils.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/zhdj")
@Slf4j
public class QAController {
    @Autowired
    private QAService qaService;

    @PostMapping("/submitquestion")
    public CommonResponse submitQuestion(@RequestBody QuestionDto questionDto) {
        log.info("questionDto:{}", questionDto);
        qaService.quest(questionDto);
        return CommonResponse.ok();
    }

    @PutMapping("/submitanswer")
    public CommonResponse submitQuestion(@RequestBody AnswerDto answerDto) {
        log.info("answerDto:{}", answerDto);
        qaService.answer(answerDto);
        return CommonResponse.ok();
    }

    @GetMapping("/getallquestion")
    public CommonResponse getAllQuestion(@RequestBody QAPageDto qaPageDto) {
        log.info("qaPageDto: {}",qaPageDto);
        PageBean questPage = qaService.getQuest(qaPageDto);
        return CommonResponse.ok(questPage);
    }

}